<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">

<!--      <h3>{{scenicName}}  度假区简介</h3>-->
      <!--<div v-if="crud.props.searchToggle">
        &lt;!&ndash; 搜索 &ndash;&gt;
        <el-input v-model="query.value" clearable placeholder="输入搜索内容" style="width: 200px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <el-select v-model="query.type" clearable placeholder="类型" class="filter-item" style="width: 130px">
          <el-option v-for="item in queryTypeOptions" :key="item.key" :label="item.display_name" :value="item.key" />
        </el-select>
        <el-date-picker
          v-model="query.businessHoursStart"
          :default-time="['00:00:00','23:59:59']"
          type="daterange"
          range-separator=":"
          size="small"
          class="date-item"
          value-format="yyyy-MM-dd HH:mm:ss"
          start-placeholder="businessHoursStartStart"
          end-placeholder="businessHoursStartEnd"
        />
        <el-date-picker
          v-model="query.businessHoursEnd"
          :default-time="['00:00:00','23:59:59']"
          type="daterange"
          range-separator=":"
          size="small"
          class="date-item"
          value-format="yyyy-MM-dd HH:mm:ss"
          start-placeholder="businessHoursEndStart"
          end-placeholder="businessHoursEndEnd"
        />
        <rrOperation :crud="crud" />
      </div>-->
      <!--如果想在工具栏加入更多按钮，可以使用插槽方式， slot = 'left' or 'right'-->
<!--      <crudOperation :permission="permission" >-->
<!--        <el-button-->
<!--          slot="right"-->
<!--          v-permission="['admin','album:back']"-->

<!--          class="filter-item"-->
<!--          size="mini"-->
<!--          type="primary"-->
<!--          @click="back"-->
<!--        >返回上一级</el-button>-->
<!--      </crudOperation>-->
      <crudOperation :permission="permission" />
      <!--表单组件-->
      <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="900px">
        <el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">

          <el-form-item label="中文介绍">
            <editor-bar v-model="form.businessHoursStart" :key="form.id" :is-clear="isClear" @change="change"  />
          </el-form-item>

          <el-form-item label="英文介绍">
            <editor-bar v-model="form.businessHoursEnd" :key="form.id" :is-clear="isClear" @change="change"  />
          </el-form-item>
<!--          <el-form-item label="特色景观">-->
<!--            <el-input :rows="3" v-model="form.characteristicSight" type="textarea" style="width: 370px;" />-->
<!--          </el-form-item>-->
<!--          <el-form-item label="建议游览时间">-->
<!--            <el-input v-model="form.tourTime" style="width: 370px;" />-->
<!--          </el-form-item>-->
<!--          <el-form-item label="价格描述">-->
<!--            <el-input :rows="3" v-model="form.price" type="textarea" style="width: 370px;" />-->
<!--          </el-form-item>-->
<!--          <el-form-item label="优惠描述">-->
<!--            <el-input :rows="3" v-model="form.discount" type="textarea" style="width: 370px;" />-->
<!--          </el-form-item>-->
<!--          <el-form-item label="游览路线">-->
<!--            <el-input :rows="3" v-model="form.route" type="textarea" style="width: 370px;" />-->
<!--          </el-form-item>-->
<!--          <el-form-item label="配套设施">-->
<!--            <el-input :rows="3" v-model="form.facilities" type="textarea" style="width: 370px;" />-->
<!--          </el-form-item>-->
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="text" @click="crud.cancelCU">取消</el-button>
          <el-button :loading="crud.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
        </div>
      </el-dialog>
      <!--表格渲染-->
      <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
        <el-table-column type="selection" width="55" />
        <el-table-column v-if="columns.visible('businessHoursStart')" :show-overflow-tooltip="true" prop="businessHoursStart" label="中文介绍" >
          <template slot-scope="scope">
            <span v-html="scope.row.businessHoursStart"></span>
          </template>
        </el-table-column>
        <el-table-column v-if="columns.visible('businessHoursEnd')" :show-overflow-tooltip="true" prop="businessHoursEnd" label="英文介绍" >
          <template slot-scope="scope">
            <span v-html="scope.row.businessHoursEnd"></span>
          </template>
        </el-table-column>
<!--        <el-table-column v-if="columns.visible('characteristicSight')" prop="characteristicSight" label="特色景观" />-->
<!--        <el-table-column v-if="columns.visible('tourTime')" prop="tourTime" label="建议游览时间" />-->
<!--        <el-table-column v-if="columns.visible('price')" prop="price" label="价格描述" />-->
<!--        <el-table-column v-if="columns.visible('discount')" prop="discount" :show-overflow-tooltip="true" label="优惠描述" />-->
<!--        <el-table-column v-if="columns.visible('route')" prop="route" :show-overflow-tooltip="true" label="游览路线" />-->
<!--        <el-table-column v-if="columns.visible('facilities')" prop="facilities" :show-overflow-tooltip="true" label="配套设施" />-->
        <el-table-column v-permission="['admin','scenicIntroduce:edit','scenicIntroduce:del']" label="操作" width="150px" align="center">
          <template slot-scope="scope">
            <udOperation
              :data="scope.row"
              :permission="permission"
            />
          </template>
        </el-table-column>
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
import crudScenicIntroduce from '@/api/scenicIntroduce'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
// import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'

import EditorBar from '@/views/components/wangEditor'

// crud交由presenter持有
const defaultCrud = CRUD({ title: '景区介绍', url: 'api/scenicIntroduce', sort: 'id,desc', crudMethod: { ...crudScenicIntroduce }})
const defaultForm = { id: null, scenicId: null, businessHoursStart: null, businessHoursEnd: null, characteristicSight: null, tourTime: null, price: null, discount: null, route: null, facilities: null }
export default {
  name: 'ScenicIntroduce',
  components: { pagination, crudOperation, udOperation,EditorBar },
  mixins: [presenter(defaultCrud), header(), form(defaultForm), crud()],
  data() {
    return {
      isClear: false,
      // scenicName:'',
      permission: {
        add: ['admin', 'scenicIntroduce:add'],
        edit: ['admin', 'scenicIntroduce:edit'],
        del: ['admin', 'scenicIntroduce:del']
      },
      rules: {
      },
      queryTypeOptions: [
      ]
    }
  },

  created() {
    this.init()
  },

  methods: {
    change(val) {
      console.log(val)
    },
    init(){
      this.form.scenicId= this.$route.query.id;
      this.scenicName=this.$route.query.name;
      console.log(this.form.scenicId);
    },

    // 获取数据前设置好接口地址
    [CRUD.HOOK.beforeRefresh]() {
      const query = this.query
      this.crud.params['scenicId'] = this.$route.query.id;
      return true
    },


    back(){
      this.$router.back(-1)
    }
  }
}
</script>

<style scoped>

</style>
